package com.dingup.api.bean.requestBean.classInfo;

import com.alibaba.fastjson.annotation.JSONField;
import com.dingup.api.Util.DateUtil;
import com.dingup.api.model.classInfo.ClassInfo;
import com.dingup.api.model.classInfo.ClassUserInfo;
import org.apache.commons.lang.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by wancheng on 2018/8/25.
 */
public class ClassInfoBean {

    private Integer id;

    private String className;

    private String classType;

    private Integer lessonId;

    private String beginTime;

    private String endTime;

    private String classTeacherId;

    private String createUserId;

    private String[] teacherIds;

    private String[] studentIds;

    @JSONField(serialize = false)
    public ClassInfo getClassInfo(){
        ClassInfo classInfo = new ClassInfo();
        classInfo.setId(this.id);
        classInfo.setClassName(this.className);
        classInfo.setClassType(this.classType);
        classInfo.setLessonId(this.lessonId);
        classInfo.setCreateUserId(this.createUserId);
        if (!StringUtils.isEmpty(beginTime)) {
            classInfo.setBeginTime(DateUtil.str2Date(beginTime, "yyyy-MM-dd"));
        }
        if (!StringUtils.isEmpty(endTime)) {
            classInfo.setEndTime(DateUtil.str2Date(endTime, "yyyy-MM-dd"));
        }
        if (studentIds != null) {
            List<ClassUserInfo> students = Arrays.stream(this.studentIds)
                    .map(ClassUserInfo::new).collect(Collectors.toList());
            classInfo.setStudents(students);
        }
        return classInfo;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassType() {
        return classType;
    }

    public void setClassType(String classType) {
        this.classType = classType;
    }

    public Integer getLessonId() {
        return lessonId;
    }

    public void setLessonId(Integer lessonId) {
        this.lessonId = lessonId;
    }

    public String getBeginTime() {
        return beginTime;
    }

    public void setBeginTime(String beginTime) {
        this.beginTime = beginTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getClassTeacherId() {
        return classTeacherId;
    }

    public void setClassTeacherId(String classTeacherId) {
        this.classTeacherId = classTeacherId;
    }

    public String[] getTeacherIds() {
        return teacherIds;
    }

    public void setTeacherIds(String[] teacherIds) {
        this.teacherIds = teacherIds;
    }

    public String[] getStudentIds() {
        return studentIds;
    }

    public void setStudentIds(String[] studentIds) {
        this.studentIds = studentIds;
    }

    public String getCreateUserId() {
        return createUserId;
    }

    public void setCreateUserId(String createUserId) {
        this.createUserId = createUserId;
    }
}
